
#ifndef WINDOW_H
#define WINDOW_H

#include <QWidget>
#include <QNetworkAccessManager>
#include <QUrl>

QT_BEGIN_NAMESPACE
class QFile;
class QAbstractItemModel;
class QModelIndex;
class QPushButton;
class QCheckBox;
class QComboBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QSortFilterProxyModel;
class QTreeView;
class QSslError;
class QAuthenticator;
class QNetworkReply;
QT_END_NAMESPACE

class Window : public QWidget
{
    Q_OBJECT

public:
    Window(QApplication *a);

    void setSourceModel(QAbstractItemModel *model);

    private slots:

        void httpFinished();

        void httpReadyRead();

        void downloadFile();

        void itemActivated ( const QModelIndex & index ) ;
private:
    QApplication* app;

    QGroupBox *accountGroupBox;
    QTreeView *accountView;
    QPushButton* refreshButton;
    QPushButton* checkButton;
    QPushButton* addButton;
    QPushButton* removeButton;
    QPushButton* exportButton;
    QPushButton* importButton;

    QGroupBox *connectionGroupBox;
    QLabel *addressLabel;
    QLabel *portLabel;
    QLabel *usernameLabel;
    QLabel *passwordLabel;
    QLabel *latencyLabel;
    QLabel *localPortLabel;
    QLineEdit *addressEdit;
    QLineEdit *portEdit;
    QLineEdit *usernameEdit;
    QLineEdit *passwordEdit;
    QLineEdit *latencyEdit;
    QLineEdit *localPortEdit;
    QCheckBox *autoConnStartupCheckBox;
    QCheckBox *autoReconnFailedCheckBox;
    QCheckBox *usingPrivateKeyCheckBox;
    QCheckBox *verboseLogCheckBox;
    QCheckBox *disablePromptCheckBox;
    QCheckBox *slowQueryCheckBox;
    QCheckBox *noLimitedRetryCheckBox;
    QCheckBox *dynamicSocketCheckBox;
    QCheckBox *hidePortCheckBox;
    QCheckBox *enableCompressionCheckBox;

    QGroupBox *keyFeatureGroupBox;
    QPushButton *hideButton;
    QPushButton *aboutButton;
    QPushButton *connectButton;
    QPushButton *exitButton;
private:
    QUrl url;
    QNetworkAccessManager qnam;
    QNetworkReply *reply;
    QFile *file;

    void addAccount(QAbstractItemModel *model, const QString &address,
        const QString &username, const QString &password,
        const QString &port, const QString &available);

    QAbstractItemModel *createMailModel(QObject *parent);

    void startRequest(QUrl url);

};

#endif
